<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org" lang="zh-cn">
<head>
<meta content="云之讯,云通讯,云通讯平台" name="keywords" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
	content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1" />
<title>短信云平台运营系统 - 编辑资源</title>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link th:href="@{/resources/css/bootstrap.min14ed.css?v=3.3.6}"
	rel="stylesheet">
<link th:href="@{/resources/css/font-awesome.min93e3.css?v=4.4.0}"
	rel="stylesheet">
<!-- jqgrid-->
<link
	th:href="@{/resources/js/plugins/jqgrid/css/ui.jqgrid-bootstrap.css}"
	rel="stylesheet">
<link th:href="@{/resources/css/animate.min.css}" rel="stylesheet">
<link th:href="@{/resources/css/style.min862f.css?v=4.1.0}"
	rel="stylesheet">

<style>
    /* Additional style to fix warning dialog position */
    #alertmod_table_list_2 {
        top: 900px !important;
    }

    .submit-title h2{
        line-height: 50px;
        border-bottom: 1px solid #DDD;
        margin-top: 0px;
        padding:0  15px;
    }

    .submit-title2 h3{
        line-height: 40px;
        border-bottom: 1px solid #DDD;
        margin-bottom: 10px;
        margin-top:0px;
        padding:0 15px;
    }

    .submit-ctx {
        background-color: #FFF;
        padding-bottom: 50px;
    }

    .radio-group label span {
        vertical-align: middle;
    }

    .radio-group input {
        margin-top: 0 !important;
        vertical-align: middle;
        position: static !important;
    }

    .other-ctx {
        display: none;
    }
</style>
</head>
<body class="gray-bg"><div th:replace="stat :: statCode"></div>
	<div class="wrapper wrapper-content  animated fadeInRight">
		<div class="ibox submit-ctx container-fluid">
			<div class="row">
				<div class="col-sm-12 submit-title">
					<h2>编辑资源</h2>
				</div>
			</div>

			<form class="form-horizontal" id="order-form">
				<!-- 通道号 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label for="channelId" class="col-sm-2 control-label">通道号</label>
						<div class="col-sm-5">
							<input type="text"
								style="position: fixed; top: -1000px; left: -3000px;">
							<input type="text" class="form-control" id="channelId"
								name="channelId" placeholder="请输入通道号" th:value="${model.channelId}">
						</div>
					</div>
				</div>
				<!-- 通道号 end -->
				<!-- 通道类型 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">通道类型</label>
						<div class="col-sm-10 radio-group">
							<label class="checkbox-inline">
								<input type="checkbox" name="channelType" th:checked="${#strings.contains(model.channelType,0)}" value="0"> <span>三网合一</span>
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="channelType" th:checked="${#strings.contains(model.channelType,1)}" value="1"> <span>移动</span>
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="channelType" th:checked="${#strings.contains(model.channelType,2)}" value="2"> <span>电信</span>
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="channelType" th:checked="${#strings.contains(model.channelType,3)}" value="3"> <span>联通</span>
							</label>
							<label class="checkbox-inline">
								<input type="checkbox" name="channelType" th:checked="${#strings.contains(model.channelType,4)}" value="4"> <span>全网</span>
							</label>
						</div>
					</div>
				</div>
				<!-- 通道类型 end -->
				<!-- 发送类型  -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">发送类型</label>
						<div class="col-sm-10 radio-group">
							<label class="checkbox-inline">
								<input type="checkbox" class="smsType" name="smsType1" th:checked="${#strings.contains(model.smsType,'纯验证码')}" value="纯验证码" data-class="smstype"> <span>纯验证码</span>
							</label> <label class="checkbox-inline"> <input type="checkbox"
								name="smsType1" class="smsType" th:checked="${#strings.contains(model.smsType,'验证码+行业通知')}" value="验证码+行业通知" data-class="smstype"> <span>验证码+行业通知</span>
							</label> <label class="checkbox-inline"> <input type="checkbox"
								name="smsType1" class="smsType" th:checked="${#strings.contains(model.smsType,'普通会员营销')}" value="普通会员营销" data-class="smstype"> <span>普通会员营销</span>
							</label> <label class="checkbox-inline"> <input type="checkbox"
								name="smsType1" class="smsType" th:checked="${#strings.contains(model.smsType,'商超')}" value="商超" data-class="smstype"> <span>商超</span>
							</label>
							<label class="checkbox-inline"> <input type="checkbox"
								name="smsType1" class="js-smstype smsType" th:checked="${#strings.contains(model.smsType,'特殊营销')}" value="" data-class="smstype-other1"> <span>特殊营销</span>
							</label>
							<label class="checkbox-inline"> <input type="checkbox" value=""
								name="smsType1" class="js-smstype smsType" th:checked="${#strings.contains(model.smsType,'其他')}" data-class="smstype-other2"> <span>其他</span>
							</label>
						</div>
					</div>
				</div>
				<div class="row other-ctx smstype-other1 smstypediv">
					<div class="form-group col-lg-7">
						<label for="contentProp" class="col-sm-2 control-label">特殊营销发送类型</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" name="marketingSmsType" id="marketingSmsType"
								placeholder="" value=""
								data-pattern="^\S{1,50}$" data-tip="特殊营销发送类型长度不能超过50个字">
						</div>
					</div>
				</div>
				<div class="row other-ctx smstype-other2 smstypediv">
					<div class="form-group col-lg-7 ">
						<label for="contentProp" class="col-sm-2 control-label">其他发送类型</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" name="otherSmsType" id="otherSmsType"
								placeholder="" value=""
								data-pattern="^\S{1,50}$" data-tip="其他发送类型长度不能超过50个字">
						</div>
					</div>
				</div>
				<input type="hidden" name="smsType">
				<!-- 发送类型 end -->
				<!-- 发送内容属性 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label for="contentProp" class="col-sm-2 control-label">发送内容属性</label>
						<div class="col-sm-3">
							<textarea class="form-control" name="contentProp"
								id="contentProp" th:text="${model.contentProp}"></textarea>
						</div>
					</div>
				</div>
				<!-- 发送内容属性 end  -->
				<!--  归属商务 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label for="belongBusiness" class="col-sm-2 control-label">归属商务</label>
						<div class="col-sm-3">
							<select class="form-control" name="belongBusiness" id="belongBusiness">
								<option th:each="businessMan:${businessManList}" th:value="${businessMan.id}"
	                                  th:selected="${model.belongBusiness} eq ${businessMan.id}"
	                                  th:text="${businessMan.realname}"></option>
							</select>
						</div>
					</div>
				</div>
				<!--  归属销售 end  -->
				<!-- 是否直连 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">是否直连</label>
						<div class="col-sm-10 radio-group">
							<label class="radio-inline"> <input type="radio"
								name="directConnect" th:checked="${model.directConnect} eq '0'"  value="0"> <span>直连</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="directConnect" th:checked="${model.directConnect} eq '1'"  value="1"> <span>第三方</span>
							</label>
						</div>
					</div>
				</div>
				<!--  是否直连 end -->
				<!--  是否支持扩展  -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">是否支持扩展</label>
						<div class="col-sm-10 radio-group">
							<label class="radio-inline"> <input type="radio"
								name="extendSize1" th:checked="${model.extendSize} eq 0" value="0" data-class="extend-other"> <span>不支持</span>
							</label> 
							<label class="radio-inline"> <input type="radio" value=""
								name="extendSize1" th:checked="${model.extendSize} gt 0"  class="js-other" data-class="extend-other">
								<span>支持</span>
							</label>
						</div>
					</div>
					<div class="form-group extend-other other-ctx col-lg-5">
						<label for="extendSize" class="col-sm-2 control-label">支持扩展位数</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" name="extendSize"
								id="extendSize" placeholder="请输入支持扩展位数 " th:value="${model.extendSize}" >
						</div>
					</div>
				</div>
				<!-- 是否支持扩展 end -->
				<!-- 签名 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">签名</label>
						<div class="col-sm-10 radio-group">
							<label class="checkbox-inline"> <input type="checkbox"
								name="signType" th:checked="${#strings.contains(model.signType,0)}" value="0"> <span>自定义</span>
							</label> <label class="checkbox-inline"> <input type="checkbox"
								name="signType" th:checked="${#strings.contains(model.signType,1)}" value="1"> <span>报备签名</span>
							</label> <label class="checkbox-inline"> <input type="checkbox"
								name="signType" th:checked="${#strings.contains(model.signType,2)}" value="2"> <span>固签</span>
							</label>
						</div>
					</div>
				</div>
				<!-- 签名 end -->
				<!-- 采购价格   -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">采购价格（元/条）</label>
						<div class="col-sm-10 radio-group">
							<label class="radio-inline"> <input type="radio"
								name="purchasePrice1" value="" class="js-other js-price js-uniform"
								data-class="uniform-other" data-str="统一价" th:checked="${#strings.contains(model.purchasePrice,'统一价')}"> <span>统一价</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="purchasePrice1" value="" class="js-other js-price"
								data-class="uniform-other" data-str="阶梯价" th:checked="${#strings.contains(model.purchasePrice,'阶梯价')}"> <span>阶梯价</span>
							</label>
						</div>
					</div>
					<div class="form-group uniform-other other-ctx col-lg-5">
						<label class="col-sm-2 control-label price-title">统一价</label>
						<div class="col-sm-3">
<!-- 							<input type="text" class="form-control" name="purchasePrice" th:value="${#strings.substring(model.purchasePrice,4)}"> -->
							<input type="text" class="form-control" name="purchasePrice" th:if="${#strings.length(model.purchasePrice)} >= 4" th:value="${#strings.substring(model.purchasePrice,4)}">
							<input type="text" class="form-control" name="purchasePrice" th:if="${#strings.length(model.purchasePrice)} < 4" value="">	
						</div>
					</div>
				</div>
				<input type="hidden" name="purchasePriceFlag" th:if="${#strings.contains(model.purchasePrice,'统一价')}" value="统一价" id="purchasePriceFlag">
				<input type="hidden" name="purchasePriceFlag" th:if="${#strings.contains(model.purchasePrice,'阶梯价')}" value="阶梯价" id="purchasePriceFlag">
				<input type="hidden" name="purchasePriceFlag" th:if="${not (#strings.contains(model.purchasePrice,'统一价') and #strings.contains(model.purchasePrice,'阶梯价'))}" value="" id="purchasePriceFlag">
				<!-- 采购价格 end -->
				<!--  速率  -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label for="rate" class="col-sm-2 control-label">速率（tps）</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="rate" name="rate"
								placeholder="" th:value="${model.rate}">
						</div>
					</div>
				</div>
				<!-- 速率 end -->
				<!-- 是否保底 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">是否保底</label>
						<div class="col-sm-10 radio-group">
							<label class="radio-inline"> <input type="radio"
								name="minimumGuarantee1" class="js-other" value=""
								data-class="insured-other" th:checked="${model.minimumGuarantee} gt '0'"> <span>保底</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="minimumGuarantee1" value="0" data-class="insured-other" th:checked="${model.minimumGuarantee} eq '0'"> <span>不承诺保底</span>
							</label>
						</div>
					</div>
					<div class="form-group insured-other other-ctx col-lg-5">
						<label for="minimumGuarantee" class="col-sm-2 control-label">保底数量</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" name="minimumGuarantee"
								id="minimumGuarantee" placeholder="" th:value="${model.minimumGuarantee}"
								data-pattern="^\d{1,10}$" data-tip="保底价格只能填写10位以内数字"> 
						</div>
						<label for="minimumGuarantee" class="col-sm-5 control-label"
							style="text-align: left;">万条/月</label>
					</div>
				</div>
				<!-- 保底价格 end -->
				<!-- 是否授信 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">是否授信</label>
						<div class="col-sm-10 radio-group">
							<label class="radio-inline"> <input type="radio"
								name="isCredit1" value="0"
								data-class="insured-other" th:checked="${model.minimumGuarantee} eq '0'"> <span>否</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="isCredit1" class="js-other" value="" data-class="iscredit-other" th:checked="${model.minimumGuarantee} gt '0'"> <span>是</span>
							</label>
						</div>
					</div>
					<div class="form-group iscredit-other other-ctx col-lg-5">
						<label for="isCredit" class="col-sm-2 control-label">授信额度</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" name="isCredit"
								id="isCredit" placeholder="" th:value="${model.isCredit}"
								data-pattern="^\d{1,11}$" data-tip="授信额度只能填写11位以内数字">
						</div>
						<label for="isCredit" class="col-sm-5 control-label"
							style="text-align: left;">万条/月</label>
					</div>
				</div>
				<!-- 是否授信 end -->
				<!-- 结算方式 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">结算方式</label>
						<div class="col-sm-10 radio-group" style="float:left;width:252px;">
							<label class="radio-inline pull-right">
								<input type="radio" value="" name="payType1" checked class="js-other" data-class="settlement-other">
                           		<span>其他</span>
							</label>
							<label class="radio-inline"> <input type="radio"
								name="payType1" value="预付" data-class="settlement-other" th:checked="${#strings.contains(model.payType,'预付')}"> <span>预付</span>
							</label>
							<label class="radio-inline"> <input type="radio"
								name="payType1" value="按月结算" data-class="settlement-other" th:checked="${#strings.contains(model.payType,'按月结算')}"> <span>按月结算</span>
							</label> 
						</div>
					</div>
					<div class="form-group settlement-other other-ctx col-lg-5">
						<label for="payType" class="col-sm-2 control-label">其他结算方式</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="payType"
								name="payType" placeholder="其他结算方式 " th:value="${model.payType}"
								data-pattern="^\S{1,50}$" data-tip="其他结算方式长度不能超过50个字">
						</div>
					</div>
				</div>
				<!--  结算方式 end -->
				<!-- 发票  -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">发票</label>
						<div class="col-sm-10 radio-group">
							<label class="radio-inline"> <input type="radio"
								name="invoiceType" th:checked="${model.invoiceType} eq 0" value="0"> <span>专票</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="invoiceType" th:checked="${model.invoiceType} eq 1" value="1"> <span>普票</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="invoiceType" th:checked="${model.invoiceType} eq 2" value="2"> <span>不要票</span>
							</label>
						</div>
					</div>
				</div>
				<!-- 发票 end -->
				<!-- 是否已接入 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">是否已接入</label>
						<div class="col-sm-10 radio-group">
							<label class="radio-inline"> <input type="radio" id="isOnline"
								name="onlineDate1" value=""
								checked data-class="insured-other"> <span>已接入</span>
							</label> <label class="radio-inline"> <input type="radio" id="isWaitOnline"
								name="onlineDate1" class="js-other" value="" data-class="isonline-other" th:checked="not ${#strings.isEmpty(model.onlineDate)}"> <span>待接入</span>
							</label>
						</div>
					</div>
					<div class="form-group isonline-other other-ctx col-lg-5" >
						<label for="onlineDate" class="col-sm-2 control-label">接入时间</label>
						<div class="col-sm-3">
							<input placeholder="接入时间" class="form-control layer-date" 
	                              name="onlineDate" id="start_time" th:value="${#dates.format(model.onlineDate,'yyyy-MM-dd')}"/>
						</div>
					</div>
				</div>
				<!-- 是否已接入 end -->
				<!-- 接入IP -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label for="mtIp" class="col-sm-2 control-label">接入IP</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="mtIp" name="mtIp"
								placeholder="请输入接入IP " th:value="${model.mtIp}"
								data-pattern="^\S{1,100}$" data-tip="接入IP长度不能超过100个字">
						</div>
					</div>
				</div>
				<!-- 接入IP end -->
				<!-- 接入协议 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label class="col-sm-2 control-label">接入协议</label>
						<div class="col-sm-10 radio-group">
							<label class="radio-inline"> <input type="radio"
								name="protocolType" th:checked="${model.protocolType} eq '0'" value="0"> <span>HTTP</span>
							</label> <label class="radio-inline" > <input type="radio"
								name="protocolType" th:checked="${model.protocolType} eq '1'" value="1"> <span>CMPP</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="protocolType" th:checked="${model.protocolType} eq '2'" value="2"> <span>SGMP</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="protocolType" th:checked="${model.protocolType} eq '3'" value="3"> <span>SGIP</span>
							</label> <label class="radio-inline"> <input type="radio"
								name="protocolType" th:checked="${model.protocolType} eq '4'" value="4"> <span>SMPP</span>
							</label>
						</div>
					</div>
				</div>
				<!-- 接入协议 end -->
				<!-- 供应商 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label for="supplier" class="col-sm-2 control-label">供应商</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="supplier" name="supplier"
								placeholder="" th:value="${model.supplier}"
								data-pattern="^\S{1,50}$" data-tip="供应商长度不能超过50个字">
						</div>
					</div>
				</div>
				<!-- 供应商 end -->
				<!-- 联系人 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label for="contact" class="col-sm-2 control-label">联系人</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="contact" name="contact"
								placeholder="" th:value="${model.contact}"
								data-pattern="^\S{1,10}$" data-tip="联系人长度不能超过10个字">
						</div>
					</div>
				</div>
				<!-- 联系人 end -->
				<!-- 手机号码 -->
				<div class="row">
					<div class="form-group col-lg-7 other-input">
						<label for="mobile" class="col-sm-2 control-label">手机号码</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="mobile" name="mobile"
								placeholder="" th:value="${model.mobile}" data-pattern="^1[34578]\d{9}$" data-tip="手机号码不合法">
						</div>
					</div>
				</div>
				<!-- 手机号码 end -->
				<!-- 备注 -->
				<div class="row">
					<div class="form-group col-lg-7">
						<label for="remark" class="col-sm-2 control-label">备注</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="remark" name="remark"
								placeholder="" th:value="${model.remark}"
								data-pattern="^\S{0,4}$" data-tip="备注长度不能超过50个字">
						</div>
					</div>
				</div>
				<!-- 备注 end -->
				<div class="row">
                 <div class="form-group col-lg-7 hide">
                   <label  class="col-sm-2 control-label">是否需要上级审批</label>
                   <div class="col-sm-10 radio-group">
                         <label class="radio-inline">
                          <input type="radio" name="isAudit"  value="0" th:checked="${model.isAudit} eq '0'" >
                          <span>否</span>
                        </label>
                        <label class="radio-inline">
                          <input type="radio" name="isAudit"  value="1" th:checked="${model.isAudit} eq '1'" >
                          <span>是</span>
                        </label>
                   </div>
                 </div>
				</div>
			 
				 <div class="row">
	                <div class="form-group col-lg-7">
	                    <div class="col-sm-offset-2 col-sm-10">
	                    	<span><input type="hidden" id="resourceId" name="resourceId" th:value="${model.resourceId}"></span>
	                        <span><button type="button" class="btn btn-success submit">提交</button></span>
	                        <span><a type="button" class="btn btn-default" th:href="@{/order/resource/view}" style="margin-left: 40px;">取消</a></span>
	                    </div>
	                </div>
	            </div>
			</form>
		</div>
	</div>
	<script th:src="@{/resources/js/jquery.min.js?v=2.1.4}"></script>
	<script th:src="@{/resources/js/jquery.form.js?v=1.0.0}"></script>
	<script th:src="@{/resources/js/bootstrap.min.js?v=3.3.6}"></script>
	<script th:src="@{/resources/js/content.min.js?v=1.0.0}"></script>
	<script th:src="@{/resources/js/plugins/layer/laydate/laydate.js}"></script>
	<script th:src="@{/resources/js/plugins/peity/jquery.peity.min.js}"></script>
	<script th:src="@{/resources/js/plugins/jqgrid/js/i18n/grid.locale-cn.js}"></script>
	<script th:src="@{/resources/js/plugins/jqgrid/js/jquery.jqGrid.min.js}"></script>
	<script th:src="@{/resources/js/date_format.min.js?v=1.0.0}"></script>
	<script th:src="@{/resources/js/common.js?v=1.0.0}"></script>
	<script th:src="@{/resources/js/layer/layer.js}"></script>

	<script th:inline="javascript">
    /*<![CDATA[*/
    var start = {
        elem: "#start_time",
        format: "YYYY-MM-DD",
        min: laydate.now(),
//         max: laydate.now(),
        start:/*[[${start_time}]]*/,
        istoday: true,
        choose: function (datas) {
            end.min = datas;
        }
    };
   
    // 已接入时没有时间空间不需要加载
    if(!$("#isOnline")[0].checked){
	    laydate(start);
    }
    
    $(document).ready(function () {
        $.jgrid.defaults.styleUI = "Bootstrap";
        
        // 发送类型赋值处理
        var smsType = /*[[${model.smsType}]]*/;
        if(smsType != null && smsType != ''){
	        var smsTypeList = smsType.split("$#");
	        $.each(smsTypeList,function(index,value){
	        	if(value.indexOf("特殊营销") != -1){
	        		$("#marketingSmsType").val(value.substring(value.indexOf("：") + 1));
	        	}
	        	if(value.indexOf("其他：") != -1){
	        		$("#otherSmsType").val(value.substring(value.indexOf("：") + 1));
	        	}
	       	});
        	
        }
       
        //js钩子 处理统一价的显示
		if($(".js-uniform")[0].checked){
			$(".price-title").text("统一价");
		} else {
			$(".price-title").text("阶梯价");
		}
        //radio 处理
        $(".js-other").each(function(){
        	var classname = $(this).data("class");
        	var target = $("." + classname);
        	
        	if(this.checked){
        		target.show();
        		target.addClass("other-input");
        	}
        })
        $(".js-other").click(function(){
        	var classname 	= $(this).data("class");
        	var target 		= $("." + classname);
        	var value = $(this).val();
        	
        	if(this.checked){
        		target.addClass("other-input")
        		target.show();
        		target.find("input").val(value)
        		/* other_target.removeClass("other-input").hide(); */
        	}else{
        		target.hide();
        	}
        })
        $("input[type='radio']").not(".js-other").click(function(){
        	var other = $(this).closest(".radio-group").find(".js-other");
        	
        	var value = $(this).val();
        	
        	var target_class = "." + other.data("class");
        	var target = $(target_class);
        	target.removeClass("other-input").hide();
        	
        	target.find("input").val(value);
        	
        })
        
      	//销售价格统一处理
      	$(".js-price").click(function(){
      		var str = $(this).data("str");
      		$(".price-title").text(str);
      		$("#purchasePriceFlag").val(str);
      	})
      	
      	// 短信类型统一处理
        $(".js-smstype").each(function(){
        	var classname = $(this).data("class");
        	var target = $("." + classname);
        	
        	if(this.checked){
        		target.show();
        	}
        })
        $(".js-smstype").click(function(){
        	var classname 	= $(this).data("class");
        	var target 		= $("." + classname);
        	
        	if(this.checked){
        		target.show();
//         		target.find("input").val(value)
        	}else{
        		target.hide();
        	}
        })
      	
        
        //表单提交
        $(".submit").click(function(){
        	var smsTypeText = [];
        	$(".smsType").each(function(){
            	var classname = $(this).data("class");
            	
            	if(this.checked){
            		if(classname == "smstype"){
            			smsTypeText.push(this.value);
            		}else{
		            	var target = $("." + classname);
		            	if(classname == "smstype-other1"){
			            	smsTypeText.push("特殊营销：" + target.find("input").val());
		            	}else{
			            	smsTypeText.push("其他：" + target.find("input").val());
		            	}
            		}
            	}
            })
            $("input[name='smsType']").val(smsTypeText.join("$#"));
        	
        	
        	var flag = true;
        	//循环所有其他的弹框，并进行验证
        	$(".other-input input").each(function(){
        		var value = $(this).val().trim();
   				var pattern = $(this).data("pattern");
   				var tip = $(this).data("tip");
   				var text = $(this).closest(".other-input").find("label").text();
        		if(value === "" || value === undefined ){
        			
        			layer.alert("请填写" + text);
                    flag = false;
                    return;
        		}
        		if(pattern != ""){
        			var reg = new RegExp(pattern);
        			if(!reg.test(value)){
        				layer.alert(tip);
        				flag = false;
        				return;
        			}
        		}
        	})
        	
        	if(!flag)
        		return;
        	
        	if($("#rate").val().length > 0 && !/^[0-9]*$/.test($("#rate").val())){
        		layer.alert("发送速率必须为正整数");
        		return;
        	}
        	var contentProp = $("#contentProp").val().trim();
        	if(contentProp.length> 100){
        		layer.alert("发送内容属性的长度不能超过100");
        		return;
        	}
        	if(contentProp === "" || contentProp === undefined){
        		layer.alert("发送内容属性不能为空");
        		return;
        	}
        	
        	// “采购价格”校验
        	var purchasePrice = $("input[name='purchasePrice']").val().trim();
        	if (purchasePrice === "" || purchasePrice === undefined) {
        		if($(".js-uniform")[0].checked){
	                layer.alert("请填写统一价");
        		}else{
	                layer.alert("请填写阶梯价");
        		}
                return;
            }
        	if($(".js-uniform")[0].checked && !(/^0\.[0-9]{1,4}$/.test(purchasePrice))){
				//选中统一价
				layer.alert("统一价格只能是小于1小数，最多保留四位");
				return;
			} else if(purchasePrice.length > 50){
				//选中阶梯价
				layer.alert("阶梯价格描述不能超过50个字符");
				return;
			}
        	
        	// 已经接入资源通道必须是开启状态
        	if($("#isOnline")[0].checked && !channelIsOpen($("#channelId").val())){
        		layer.alert("通道号对应的通道不存在或者没有开启");
				return;
        	}
        	
        	// 发送类型为“特殊营销”和“其他”的输入框校验
        	$(".js-smstype").each(function(){
	        	var classname = $(this).data("class");
	        	var target = $("." + classname);
	        	
	        	if(this.checked){
	        		var input = target.find("input");
	        		var value = $(input).val().trim();
	   				var pattern = $(input).data("pattern");
	   				var tip = $(input).data("tip");
	   				var text = $(input).closest(".other-ctx").find("label").text();
	        		if($(input).val() === "" || $(input).val() === undefined ){
	        			
	        			layer.alert("请填写" + text);
	                    flag = false;
	                    return;
	        		}
	        		if(pattern != ""){
	        			var reg = new RegExp(pattern);
	        			if(!reg.test(value)){
	        				layer.alert(tip);
	        				flag = false;
	        				return;
	        			}
	        		}
	        	}
	        })

            var options = {
                beforeSubmit: function () {
//                    $(btn).attr("disabled", true);
                },
                success: function (data) {
//                    $(btn).attr("disabled", false);
                    if (data == "" || data == null) {
                        return; //session超时
                    }
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1500}, function () {
                            var mainUrl = /*[[@{/order/resource/view}]]*/'';
                            window.location.href = mainUrl;
                        });
                    } else {
                    	layer.alert(data.msg);
                    }
                },
                url: /*[[@{/order/resource/edit/save}]]*/'',
                type: "post"
            };
        	flag && $("#order-form").ajaxSubmit(options);
        })
    });
    
    function channelIsOpen(channelId){
    	var isOpen = false;
    	$.ajax({
    		type: "GET",
    		dataType: "json",
    		data : {
    			channelId : channelId
    		},
    		async : false,
    		url: /*[[@{/order/resource/channelIsOpen}]]*/,
    		success: function(result){
    			if(result != null && result.data != null){
    				isOpen = result.data;
    			}
    		}
    	});
    	
    	return isOpen;
    }
    /*]]>*/
//@ sourceURL= resource-add.js
</script>
</body>
</html>